package com.wc.alorithm_luogu.P2058;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.ArrayList;
import java.util.HashSet;

/**
 * @Author congge
 * @Date 2023/5/16 11:50
 * @description https://www.luogu.com.cn/problem/P2058
 * [NOIP2016 普及组] 海港 (滑动窗口)
 */
public class Main {
    public static void main(String[] args) {
        Input sc = new Input();

        int n = sc.nextInt();

        // 用作滑动窗口
        int[] times = new int[n];
        // 装船上不同的国籍
        ArrayList<HashSet<Integer>> boats = new ArrayList<>();

        // 当前时间
        int curTime;
        // 当前人数
        int curPeopleNum;
        // 当前人的国籍
        int curPeopleCountry;

        // 当前国籍
        int[] peopleCountry = new int[3 * 100000 + 5];

        // 当前最大国籍
        int maxCountry = -1;

        // 当前船只
        HashSet<Integer> curBoat;
        for (int i = 0; i < n; i++) {
            curTime = sc.nextInt();
            curPeopleNum = sc.nextInt();
            times[i] = curTime;
            curBoat = new HashSet<>();
            boats.add(curBoat);
            for (int j = 0; j < curPeopleNum; j++) {
                curPeopleCountry = sc.nextInt();
                maxCountry = Math.max(maxCountry, curPeopleCountry);
                curBoat.add(curPeopleCountry);
            }

        }

        int[] ans = new int[n];

        // 当前最多国家的人
        HashSet<Integer> curMaxCountry = new HashSet<>();

        int left = 0;

        for (int i = 0; i < n; i++) {
            curBoat = boats.get(i);
            for (int curPeople : curBoat) {
                curMaxCountry.add(curPeople);
                peopleCountry[curPeople]++;
            }
            while (times[i] - 86400 >= times[left]) {
                HashSet<Integer> preBoat = boats.get(left);
                for (int curPeople : preBoat) {
                    peopleCountry[curPeople]--;
                    if (peopleCountry[curPeople] == 0) {
                        curMaxCountry.remove(curPeople);
                    }
                }
                left++;
            }
            ans[i] = curMaxCountry.size();
        }

        //展示
        for (int i = 0; i < n; i++) {
            System.out.println(ans[i]);
        }
    }



    static class Input {
        StreamTokenizer in = new StreamTokenizer
                (new BufferedReader(new InputStreamReader(System.in)));

        public int nextInt() {
            try {
                in.nextToken();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (int) in.nval;
        }
    }
}
